export const mutations = {
    addCart(state, goodsInfo) {
        console.log(state)
        let oldGoodsInfo = state.carList.find(item => item.iid == goodsInfo.iid)
        if (oldGoodsInfo) {
            oldGoodsInfo.count++
        } else {
            goodsInfo.count = 1
            goodsInfo.checked = true
            state.carList.push(goodsInfo)
        }
    },
    addCount(state, iid) {
        let goodsInfo = state.carList.find(item => item.iid == iid)
        goodsInfo.count++

    },
    subCount(state, iid) {
        let goodsInfo = state.carList.find(item => item.iid == iid)
        goodsInfo.count--
    },
    updatedChecked(state, status) {
        state.carList.map(item => { item.checked = !status })
    },
    updatedOneChecked(state, iid) {
        let goodsInfo = state.carList.find(item => item.iid == iid)
        goodsInfo.checked = !goodsInfo.checked
    },
    delGoods(state, index) {
        state.carList.splice(index, 1)
    }
}
